/*
 * Copyright (c) 2021 Futurewei Technologies, Inc.
 *
 * clang2mpl is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PSL v2. You may obtain a copy of Mulan PSL v2 at:
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the
 * Mulan PSL v2 for more details.
 */
// RUN: %clang2mpl --ascii --verify %s -- -Wno-unused-value --target=aarch64-linux-elf
// RUN: cat %m | %FileCheck %s
#include <stdalign.h>

void foo(int x) {
  short a1[4][3];
  // TODO: Variable length arrays are not yet supported in Maple
  // int a2[x + 3];
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 2
  sizeof(short);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 4
  sizeof(x);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 16
  sizeof(int[4]);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 32
  sizeof(char[4][8]);
  // CHECK: LOC 2 [[# @LINE + 4 ]]{{$}}
  // CHECK-NEXT: mul u64 (
  // CHECK-NEXT:   constval u64 4,
  // CHECK-NEXT:   cvt u64 i32 (mul i32 (constval i32 2, dread i32 %x)))
  sizeof(int[2 * x]);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 24
  sizeof(a1);
  // HECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // HECK-NEXT: mul u64 (
  // HECK-NEXT:    cvt u64 i32 (add i32 (dread i32 %x, constval i32 3)),
  // HECK-NEXT:    constval u64 4)
  // sizeof(a2);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 8
  alignof(long long);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 2
  alignof(short[x * x]);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 4
  __alignof(float);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 4
  __alignof(x);
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: constval u64 1
  __alignof(char[x << 3]);
}
